Phase-2 structural pilots: IC context type, unified BC dispatcher, boundary module split#1555
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1555 +/- ##
==========================================
- Coverage 61.17% 60.94% -0.24%
==========================================
Files 74 77 +3
Lines 20313 19921 -392
Branches 2961 2924 -37
==========================================
- Hits 12427 12141 -286
+ Misses 5870 5804 -66
+ Partials 2016 1976 -40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f2fbd24 to
bb23704
Compare
fluid_pp%{mul0,ss,pv,gamma_v,M_v,mu_v,k_v,cp_v,D_v} and
lag_params%{T0,Thost,c0,rho0,x0} were removed from the Fortran derived
types by upstream MFlowCode#1085/MFlowCode#1093 but remained registered in the toolchain.
Setting any of them causes namelist read to abort with a misleading
'datatype mismatch' error.
Verified against src/common/m_derived_types.fpp:
- physical_parameters has: gamma, pi_inf, Re, cv, qv, qvp, G
- bubbles_lagrange_parameters has: solver_approach, cluster_type,
pressure_corrector, smooth_type, heatTransfer_model, massTransfer_model,
write_bubbles, write_bubbles_stats, nBubs_glb, epsilonb, charwidth, valmaxvoid
Also remove the now-dead PATTERNS entries in descriptions.py and update
the stale comments in fortran_gen.py (_emit_fluid_pp and _emit_lag_params).
Both emitters now walk the registry rather than hardcoding member lists.
bc_x/y/z%{vb1,vb2,vb3,ve1,ve2,ve3} are read from the namelist on rank 0
and consumed on all ranks by s_slip_wall/s_no_slip_wall in
src/common/m_boundary_common.fpp (~833-1155). These routines are compiled
into all three targets and are reached from pre_process (m_data_output,
m_perturbation) and post_process (m_start_up) code paths.
Without the broadcast, non-root ranks use uninitialised values for the
wall-velocity components, producing rank-dependent ghost cells for any
multi-rank wall-BC pre-process or post-process run. The sim residue has
always broadcast these; pre and post were missing them.
Add the matching broadcasts to both pre and post using the same nested
Fypp loop idiom as the simulation residue.
muscl_eps was excluded from broadcast generation via _BCAST_EXCLUDE on the incorrect assumption that it is derived post-broadcast. The derivation (in m_weno or m_muscl) only fires under f_is_default(muscl_eps), and default values are assigned on rank 0 only. Every multi-rank MUSCL run therefore had rank-divergent muscl_eps on non-root ranks. Remove it from the exclusion set. Tuple-set delta (var, mpi_type, count) vs. HEAD~: sim: +1 entry: (muscl_eps, mpi_p, 1) pre: no change post: no change _emit_fluid_pp and _emit_lag_params now walk the registry instead of maintaining hardcoded member lists. After Commit 1 deregistered the dead members (mul0/ss/pv/gamma_v/M_v/mu_v/k_v/cp_v/D_v for fluid_pp; T0/Thost/c0/rho0/x0 for lag_params), the registry now matches the Fortran types exactly. Re(1) count=2 remains sim-only via an explicit target check with a comment. G is walked as a regular REAL member. Tests: 3 new tests added — muscl_eps now broadcast in sim, fluid_pp and lag_params registry walks produce exactly the registered members minus documented exclusions, dead members absent.
…idue broadcasts pre_process sent the integer bc_x/y/z%beg/%end with mpi_p (an 8-byte real transfer over 4-byte integers - undefined behavior that happened to work by adjacency); simulation and post_process already used MPI_INTEGER. Also adds a test pinning the hand-written vb/ve and BC-code residue in pre/post so a merge conflict cannot silently drop them. Both from review.
bb23704 to
2eff838
Compare
Cowsreal
pushed a commit
to Cowsreal/MFCMarkZhang
that referenced
this pull request
Jun 24, 2026
…undary module split (MFlowCode#1555)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context derived type (pilot for state-bundling). pre_process's five module-level initial-condition arrays (
q_prim_vf,q_cons_vf,q_T_sf,bc_type,patch_id_fp) bundle into oneic_contextinm_derived_types— plain data, no methods, mixed-precision variant preserved. Other modules' signatures are untouched (they already received these as arguments). +2 net LOC; emitted-Fortran equivalence verified (zero executable-statement diffs after qualifying the references).Direction-unified BC dispatcher (pilot for de-triplication).
s_populate_variables_bufferscarried six near-identical x/y/z-beg/end blocks; they collapse into one parameterizeds_populate_bc_direction(bc_dir, bc_loc, ...). −105 net LOC. Behavior preserved exactly per (direction, location) pair, including a subtlety the original encodes: only y-beg dispatchesBC_AXISand excludes it from qbmm extrapolation — y-end does not, and the unified guard reproduces that asymmetry. GPU directive census: six identicalGPU_PARALLEL_LOOPshells become one (with one added private scalar); both backends, otherwise unchanged. The BC-code read is hoisted to a loop-private, and thebc_typeedge is passed as aninteger_fieldso the helper contains no constant direction subscripts (keeps case-optimized 1D builds compiling).Module split (pilot for giant-file decomposition).
m_boundary_common.fpp(2,250 lines) splits into the dispatcher+lifecycle core (194 lines),m_boundary_primitives(the eight GPU_ROUTINE BC helpers + the device-residentbc_buffers), andm_boundary_io(capillary/IGR buffers, MPI types, restart read/write, grid buffers). Pure code motion: statement-multiset of the union equals the parent file per target; GPU-directive multiset md5-identical. The original module re-exports everything it used to own, so zero external callers change. One deliberate deviation from the plan is documented in-code:bc_bufferslives inm_boundary_primitives(its on-device consumer) rather than the core module, avoiding a use-cycle with the re-export.Verification
.f90statement-set equivalence (pilots 1, 3), six-way per-(dir,loc) behavior table and GPU-directive census (pilot 2), re-export resolution audit covering all 13 external consumer files (pilot 3).Notes for reviewers
m_riemann_solverssplit) — feedback on the patterns here shapes those.